-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: add tests for TbdexQuoteNotifier
#321
test: add tests for TbdexQuoteNotifier
#321
Conversation
}); | ||
|
||
group('TbdexQuoteNotifier Stress Tests', () { | ||
test('High-frequency polling with exponential backoff', () async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as #312 (comment)
.thenAnswer((_) async => TestData.getExchange()); | ||
}); | ||
|
||
group('TbdexQuoteNotifier Stress Tests', () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's rename this group to just TbdexQuoteNotifier
take a look at the tests for |
Hey @ethan-tbd Check out the latest changes. |
|
||
await mockTbdexQuoteNotifier.startPolling('pfiId', 'exchangeId'); | ||
|
||
verify(() => mockTbdexQuoteNotifier.startPolling(any(), any())).called(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the reason we are using any()
here in startPolling()
?
test('should handle maximum retry attempts', () async { | ||
when(() => mockTbdexQuoteNotifier.pollForQuote(any(), any())) | ||
.thenThrow(Exception('Network error')); | ||
|
||
await mockTbdexQuoteNotifier.startPolling('pfiId', 'exchangeId'); | ||
|
||
verify(() => mockTbdexQuoteNotifier.startPolling('pfiId', 'exchangeId')) | ||
.called(1); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are throwing an Exception
here but the test case only checks to see if startPolling()
has been called
test('should handle high-frequency polling with exponential backoff', | ||
() async { | ||
when(() => mockTbdexQuoteNotifier.pollForQuote(any(), any())) | ||
.thenAnswer((_) async => TestData.getQuote()); | ||
|
||
await mockTbdexQuoteNotifier.startPolling('pfiId', 'exchangeId'); | ||
|
||
verify(() => mockTbdexQuoteNotifier.startPolling('pfiId', 'exchangeId')) | ||
.called(1); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you want to test the exponential backoff, try verifying how many times getExchange()
is called
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work!
This PR introduces several tests for
TbdexQuoteNotifier
.closes #293